import { CommonModel, ListResponse, PagerQuery } from '.'
import { authorizeRequest } from '../util/http'

const ROUTE = '/v1/comments'

export interface Comment extends CommonModel {
    content: string;
    userId: number;
    pictureId: number;
    username: string;
    nickname: string;
}
export interface GetCommentListRequest extends PagerQuery {
    pictureId: number;
}
export type CommentListResponse = ListResponse<Comment>
export const apiGetCommentList = async (params: GetCommentListRequest) => {
    return (await authorizeRequest.get<CommentListResponse>(ROUTE, { params: params })).data
}

export interface CreateCommentRequest {
    content: string;
    pictureId: number;
}
export const apiPostComment = async (params: CreateCommentRequest) => {
    return (await authorizeRequest.post<object>(ROUTE, params)).data
}